<template>
	<el-menu default-active="2" style="height: 100%;" :unique-opened="true" background-color="#3c495c" text-color="#fff" active-text-color="#0c64eb" router>
		<el-submenu v-for="menu in menus" :index="menu.id + ''" :key="menu.id">
			<template slot="title">
				<span>{{ menu.name }}</span>
			</template>
			<ChilrenMenu v-for="item in menu.children" :menu="item" :key="item.id" @click.native="clickMenu(item)"></ChilrenMenu>
		</el-submenu>

		<!-- <el-submenu index="1">
			<template slot="title">
				<span>系统管理</span>
			</template>
			<el-menu-item index="/role">角色管理</el-menu-item>
			<el-menu-item index="/permission">权限管理</el-menu-item>
			<el-menu-item index="/user">用户管理</el-menu-item>
			<el-menu-item index="/territory">我的地盘</el-menu-item>
		</el-submenu> -->
	</el-menu>
</template>

<script>
import axios from '../utils/axiosutils.js';
import ChilrenMenu from '@/components/childrenMenu';
export default {
	name: 'WyMenu',
	components: {
		ChilrenMenu
	},
	data() {
		return {
			menus: []
		};
	},
	created() {
		axios.post(
			'/permission/userPermissionList',
			response => {
				this.menus = response.obj;
			},
			{}
		);
	},
	methods: {
		clickMenu(item) {
			
			this.$store.commit('selectMenu', item);
			
		}
	}
};
</script>

<style scoped></style>
